<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script type="text/javascript">   
function noNumbers(e) 
{
	alert(e)
var keynum;   
var keychar;   
var numcheck;   
  
if(window.event) // IE   
    {   
    keynum = e.keyCode;
    }   
else if(e.which) // Netscape/Firefox/Opera   
    {   
    keynum = e.which;
    }   
keychar = String.fromCharCode(keynum);   
alert(keychar)   
numcheck = /\d/;   
return !numcheck.test(keychar);   
}   
</script>
  
<form>   
Type some text (numbers not allowed):   
<input type="text" onkeydown="return noNumbers(event)" />   
</form>
<p>//如果输入回车，则提交表单 <br />
</p>
<pre name="code">&lt;input type=&quot;text&quot; onkeydown=&quot;if(event.keyCode==13)document.forms[0].submit();&quot;/&gt;
</pre>
</body>
</html>
